﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SuKienMaster.Master" AutoEventWireup="true" CodeBehind="DanhSachKH.aspx.cs" Inherits="QuanLySuKien.DanhSachKH1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentMain" runat="server">

<asp:Table ID="Table1" runat="server">
            <asp:TableRow>
                <asp:TableCell>
                    <asp:Label ID="filterLabel" runat="server" Text="Tìm kiếm theo tên khách hàng:"
                     AssociatedControlID="filterTextBox"></asp:Label>
                </asp:TableCell>
                <asp:TableCell>
                    <asp:TextBox  ID="filterTextBox" runat="server" MaxLength="50"></asp:TextBox>
                </asp:TableCell>
                <asp:TableCell>
                    <asp:Button ID="refreshButton" runat="server" Text="Search" CausesValidation="false" />
                </asp:TableCell>
            </asp:TableRow>
       </asp:Table>
        <asp:Label ID="StatusLabel" runat="server"></asp:Label>
<asp:listview ID="Listview1" runat="server" DataKeyNames="UserName" 
        DataSourceID="SqlDataSource1" EnableModelValidation="True" 
        InsertItemPosition="LastItem" >
        <AlternatingItemTemplate>

        </AlternatingItemTemplate>
        <EditItemTemplate>
            <li style="background-color: #FFCC66; color: #000080;">
                <asp:Label ID="UserIdLabel1" runat="server" Text='<%# Eval("UserName") %>' Visible="false" />
                <br />
                <div class="labelFormKH">
                Họ tên:
                <br />
                <br />
                Ngày sinh:
                <br />
                <br />
                Số điện thoại:
                <br />
                <br />
                Địa chỉ Email:
                <br />
                <br />
                Địa chỉ:
                <br />
                <br />
                Mô tả:
                <br />
                <br />
                <br />
                <br />
                </div>
                <div class="textboxFormKH">
                <asp:TextBox ID="HoTenTextBox" runat="server" Text='<%# Bind("HoTen") %>' Width="400" />
                                 <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                 ControlToValidate="HoTenTextBox" Display="Dynamic"
                                 ErrorMessage="Không được để trống"></asp:RequiredFieldValidator>
                <br />
                
                <asp:TextBox ID="NgaySinhTextBox" runat="server" Text='<%# Bind("NgaySinh") %>' Width="400"/>
                <br />
                
                <asp:TextBox ID="SoDTTextBox" runat="server" Text='<%# Bind("SoDT") %>' Width="400" />
               <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                                                ControlToValidate="SoDTTextBox" Display="Dynamic" 
                                                ErrorMessage="Không được để trống"></asp:RequiredFieldValidator>
                                            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                                                ControlToValidate="SoDTTextBox" Display="Dynamic" 
                                                ErrorMessage="Số điện thoại không hợp lệ" ValidationExpression="[0-9.]{8,12}"></asp:RegularExpressionValidator>
                <br />
                
                <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' Width="400" />
                
                                  <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                 ControlToValidate="EmailTextBox"
                                 Display="Dynamic" ErrorMessage="Không được để trống"></asp:RequiredFieldValidator>
                                 <asp:RegularExpressionValidator ID="KhachHangEmailTextBoxREV"
                                 runat="server" ControlToValidate="EmailTextBox" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                 Display="Dynamic" ErrorMessage=" Email không tồn tại."></asp:RegularExpressionValidator>
                <asp:TextBox ID="DiaChiTextBox" runat="server" Text='<%# Bind("DiaChi") %>'  Width="400" />
                                 <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                                 ControlToValidate="DiaChiTextBox" Display="Dynamic"
                                 ErrorMessage="Không được để trống"></asp:RequiredFieldValidator>
                <br />
                
                <asp:TextBox ID="MotaTextBox" runat="server" Text='<%# Bind("Mota") %>' Width="400" />
                <br />
                <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                    Text="Cập nhật" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                    Text="Hủy bỏ" />
                    </div>
                     <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
            </li>
           
        </EditItemTemplate>
        <EmptyDataTemplate>
            No data was returned.
        </EmptyDataTemplate>
        <InsertItemTemplate>
        </InsertItemTemplate>
        <ItemSeparatorTemplate>
        </ItemSeparatorTemplate>
        <itemtemplate>
       <div class="dscomment">
            <div class="thongtinuser">
             <img ID="img1" alt="" width="60" runat="server" src="~/img/customers_icon.gif"/>
            <br />
            Khách:
             <b>
            <asp:Label ID="HoTenlabel" runat="server" Text='<%# Eval("HoTen") %>'  />
            </b>
            <br />
             <td>
                <asp:LinkButton ID="Button1" runat="server" CommandName="Edit" Text="Sửa" />
                <asp:LinkButton ID="DeleteButton" runat="server" CommandName="Delete" 
                    Text="Xóa"  OnClientClick="return confirm('Bạn muốn xóa khách hàng này?');" />
            </td>
            </div>


            <div class="thongtincomment1"> 

             Ngày sinh
            <br />

             Số điện thoại
            <br />

            Địa chỉ Email

            <br />

            Địa chỉ

            <br />
            Mô tả

            <br />
            </div>

            <div class="thongtincomment2"> 

            <b>
             <asp:Label ID="Label1" runat="server" Text='<%# Eval("NgaySinh") %>'/> 
            </b>
            <br />

            <b>
            <asp:Label ID="Label2" runat="server" Text='<%# Eval("SoDT") %>'  />
            </b>
            <br />

            <b>
            <asp:Label ID="Label3" runat="server" Text='<%# Eval("Email") %>'  />
            </b>
            <br />

            <b>
            <asp:Label ID="Label4" runat="server" Text='<%# Eval("DiaChi") %>'  />
            </b>
            <br />

            <b>
            <asp:Label ID="Label5" runat="server" Text='<%# Eval("MoTa") %>'  />
            </b>
            <br />
            </div>
            <div style="clear:both"></div>
       </div>
           
    </itemtemplate>
        <LayoutTemplate>
            <ul ID="itemPlaceholderContainer" runat="server" 
                style="font-family: Verdana, Arial, Helvetica, sans-serif;">
                <li runat="server" id="itemPlaceholder" />
            </ul>
            <div style="text-align: center; background-color: #FFCC66; font-family: Verdana, Arial, Helvetica, sans-serif; color: #333333;">
                <asp:DataPager ID="DataPager1" runat="server">
                    <Fields>
                        <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                            ShowLastPageButton="True" FirstPageText="Về đầu" LastPageText="Về cuối" NextPageText="Tiếp" PreviousPageText="Về trước" />
                    </Fields>
                </asp:DataPager>
            </div>
        </LayoutTemplate>
        <SelectedItemTemplate>
            <li style="background-color: #FFCC66; font-weight: bold; color: #000080;">UserName:
                <asp:Label ID="UserIdLabel" runat="server" Text='<%# Eval("UserName") %>' />
                <br />
                HoTen:
                <asp:Label ID="HoTenLabel" runat="server" Text='<%# Eval("HoTen") %>' />
                <br />
                NgaySinh:
                <asp:Label ID="NgaySinhLabel" runat="server" Text='<%# Eval("NgaySinh") %>' />
                <br />
                SoDT:
                <asp:Label ID="SoDTLabel" runat="server" Text='<%# Eval("SoDT") %>' />
                <br />
                Email:
                <asp:Label ID="EmailLabel" runat="server" Text='<%# Eval("Email") %>' />
                <br />
                DiaChi:
                <asp:Label ID="DiaChiLabel" runat="server" Text='<%# Eval("DiaChi") %>' />
                <br />
                Mota:
                <asp:Label ID="MotaLabel" runat="server" Text='<%# Eval("Mota") %>' />
                <br />
                <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
            </li>
        </SelectedItemTemplate>
    </asp:listview> 
 
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:quanlysukienConnectionString4 %>" 
        DeleteCommand="DELETE FROM [ThongTinKH] WHERE [UserName] = @original_UserName" 
        InsertCommand="INSERT INTO [ThongTinKH] ([UserName], [HoTen], [NgaySinh], [SoDT], [Email], [DiaChi], [Mota]) VALUES (@UserName, @HoTen, @NgaySinh, @SoDT, @Email, @DiaChi, @Mota)" 
        OldValuesParameterFormatString="original_{0}" 
        SelectCommand="SELECT [UserName], [HoTen], [SoDT], [Email], [DiaChi], [Mota], convert(varchar,NgaySinh,105) AS NgaySinh FROM [ThongTinKH]" 
        UpdateCommand="UPDATE [ThongTinKH] SET [HoTen] = @HoTen, [NgaySinh] = @NgaySinh, [SoDT] = @SoDT, [Email] = @Email, [DiaChi] = @DiaChi, [Mota] = @Mota WHERE [UserName] = @original_UserName">
        <DeleteParameters>
            <asp:Parameter Name="original_UserName" Type="Object" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="UserName" Type="String" />
            <asp:Parameter Name="HoTen" Type="String" />
            <asp:Parameter Name="NgaySinh" Type="DateTime" />
            <asp:Parameter Name="SoDT" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="DiaChi" Type="String" />
            <asp:Parameter Name="Mota" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="HoTen" Type="String" />
            <asp:Parameter Name="NgaySinh" Type="DateTime" />
            <asp:Parameter Name="SoDT" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="DiaChi" Type="String" />
            <asp:Parameter Name="Mota" Type="String" />
            <asp:Parameter Name="original_UserName" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>

    </asp:Content>
